<?php
/**
 * Display banners on settings page
 * @package Captcha by BestWebSoft
 * @since 4.1.5
 */

/**
 * Show ads for PRO
 * @param     string     $func        function to call
 * @return    void
 */
if ( ! function_exists( 'cptch_pro_block' ) ) {
	function cptch_pro_block( $func, $show_cross = true, $display_always = false ) {
		global $cptch_plugin_info, $wp_version, $cptch_options;
		if ( $display_always || ! bws_hide_premium_options_check( $cptch_options ) ) { ?>
			<div class="bws_pro_version_bloc <?php echo $func;?>" title="<?php _e( 'This options is available in Pro version of plugin', 'captcha' ); ?>">
				<div class="bws_pro_version_table_bloc">
					<?php if ( $show_cross ) { ?>
						<button type="submit" name="bws_hide_premium_options" class="notice-dismiss bws_hide_premium_options" title="<?php _e( 'Close', 'captcha' ); ?>"></button>
					<?php } ?>
					<div class="bws_table_bg"></div>
					<?php call_user_func( $func ); ?>
				</div>
				<div class="bws_pro_version_tooltip">
					<a class="bws_button" href="https://bestwebsoft.com/products/wordpress/plugins/captcha/?k=9701bbd97e61e52baa79c58c3caacf6d&pn=75&v=<?php echo $cptch_plugin_info["Version"]; ?>&wp_v=<?php echo $wp_version; ?>" target="_blank" title="Captcha Pro by BestWebSoft Plugin"><?php _e( 'Upgrade to Pro', 'captcha' ); ?></a>
					<div class="clear"></div>
				</div>				
			</div>
		<?php }
	}
}

if ( ! function_exists( 'cptch_whitelist_banner' ) ) {
	function cptch_whitelist_banner() { ?>
		<div class="bws_pro_version">
			<div class="bws_info" style="line-height: 2;"><?php _e( "Allowed formats", 'captcha' ); ?>:&nbsp;<code>192.168.0.1, 192.168.0., 192.168., 192., 192.168.0.1/8, 123.126.12.243-185.239.34.54</code></div>
			<div class="bws_info" style="line-height: 2;"><?php _e( "Allowed separators for IPs: a comma", 'captcha' ); ?> (<code>,</code>), <?php _e( 'semicolon', 'captcha' ); ?> (<code>;</code>), <?php _e( 'ordinary space, tab, new line or carriage return', 'captcha' ); ?></div>	
			<?php _e( 'Reason', 'captcha' ); ?><br>
			<textarea disabled></textarea>					
			<div class="bws_info" style="line-height: 2;"><?php _e( "Allowed separators for reasons: a comma", 'captcha' ); ?> (<code>,</code>), <?php _e( 'semicolon', 'captcha' ); ?> (<code>;</code>), <?php _e( 'tab, new line or carriage return', 'captcha' ); ?></div>
		</div>
	<?php }
}

/**
 *
 * @since 4.2.3
 */
if ( ! function_exists( 'cptch_additional_options' ) ) {
	function cptch_additional_options() {
		$src = plugins_url( 'images/package/', dirname( __FILE__ ) ); ?>
		<table class="form-table bws_pro_version">
			<tr>
				<th scope="row"><?php _e( 'General Settings', 'captcha' ); ?></th>
				<td>
					<input type="checkbox" disabled="disabled" /> 
					<span class="bws_info"><?php _e( 'Enable to use general captcha settings.', 'captcha' ); ?></span>
				</td>
			</tr>
			<tr class="cptch_form_option_used_packages">
				<th scope="row"><?php _e( 'Image Packages', 'captcha' );?></th>
				<td>
					<fieldset>
						<div class="cptch_tabs_package_list cptch_pro_pack_tab">
							<ul class="cptch_tabs_package_list_items">
								<li>
									<span><input type="checkbox" disabled="disabled" /></span>
									<span><img src="<?php echo $src; ?>arabic_bt/0.png"></span>
									<span>Arabic ( black numbers - transparent background )</span>
								</li>
								<li>
									<span><input type="checkbox" disabled="disabled" /></span>
									<span><img src="<?php echo $src; ?>arabic_bw/0.png"></span>
									<span>Arabic ( black numbers - white background )</span>
								</li>
								<li>
									<span><input type="checkbox" disabled="disabled" /></span>
									<span><img src="<?php echo $src; ?>arabic_wb/0.png"></span>
									<span>Arabic ( white numbers - black background )</span>
								</li>
							</ul>
						</div>
					</fieldset>
				</td>
			</tr>
			<tr>
				<th scope="row"><?php _e( 'Time Limit', 'captcha' ); ?></th>
				<td>
					<input type="checkbox" disabled="disabled">
					<span class="bws_info"><?php _e( 'Enable to activate a time limit requeired to complete captcha.', 'captcha' ); ?></span>
				</td>
			</tr>
		</table>
	<?php }
}

/**
 *
 * @since 4.2.3
 */
if ( ! function_exists( 'cptch_use_several_packages' ) ) {
	function cptch_use_several_packages() { ?>
		<table class="form-table cptch_enable_to_use_several_packages bws_pro_version">
			<tr>
				<th scope="row"><?php _e( 'Use Several Image Packages at The Same Time', 'captcha' );?></th>
				<td><fieldset><input type="checkbox" disabled="disabled" /></fieldset></td>
			</tr>
		</table>
	<?php }
}

/**
 * Function disable's pro-tabs displaing beyond the main settings page
 * @since 4.3.1
 * @param  void
 * @return void
 */
if ( ! function_exists( 'hide_pro_tabs_beyond_settings_page' ) ) {
	function hide_pro_tabs_beyond_settings_page() {
		if ( isset( $_POST['bws_hide_premium_options'] ) ) {
			global $cptch_options;

			/* options changing */
			$result = bws_hide_premium_options( $cptch_options );

			/* return if options had been disabled earlier */
			if ( true === $result )
				return;

			/* changin the globol variable */
			$cptch_options = $result['options'];

			update_option( 'cptch_options', $cptch_options ); ?>

			<div class="updated bws-notice inline"><p><strong><?php if ( ! empty( $result['message'] ) ) echo $result['message']; ?></strong></p></div>
		<?php }
	}
}